import Layout from "../layout.js"
import D from "../delegator.js"

export default class UIProperty {
    constructor() {
        this.element = Layout.CreateProperty();

         this._modifyElem = D(this.element).Qe('#slog_property_radio_modify');
         this._nameElem = D(this.element).Qe('#slog_property_name');
         this._tagElem = D(this.element).Qe('#slog_property_tag');
         this._createTimeElem = D.Qe('#slog_property_create');
         this._modifyTimeElem = D.Qe('#slog_property_modify');
         this._publishedElem = D.Qe('#slog_property_published');
         this._useTOC = D.Qe('#slog_property_TOC');
         this._briefElem = D.Qe('#slog_property_brief');
    }

    SetCaption(value) {this.element.querySelector('h5.modal-title').innerText = value;}
    SetName(value) {this._nameElem.value = value;}
    GetName() {return this._nameElem.value;}
    SetTag(value) {this._tagElem.value = value.join(' ');}
    GetTag() {return this._tagElem.value.split(' ');}
    SetCreateTime(value) {this._createTimeElem.value = value;}
    GetCreateTime() {return this._createTimeElem.value;}
    SetModifyTime(value) {this._modifyTimeElem.value = value;}
    GetModifyTime() {return this._modifyTimeElem.value;}
    SetPublished(value) {this._publishedElem.checked = value;}
    GetPublished() {return this._publishedElem.checked;}
    SetUseTOC(value) {this._useTOC.checked = value;}
    GetUseTOC() {return this._useTOC.checked;}
    SetBrief(value) {this._briefElem.value = value;}
    GetBrief() {return this._briefElem.value;}

    Focus(){
        this._nameElem.focus();
    }

    ShowCreate() {
        this.element.querySelector('div.modal-footer').innerHTML = `<button type="button" class="btn btn-primary">Create</button>`;
        this.createButton = this.element.querySelector('.btn.btn-primary');
    }
    ShowModify() {
        this.element.querySelector('div.modal-footer').innerHTML = `<button type="button" class="btn btn-danger">Delete</button> <button type="button" class="btn btn-primary">Confirm</button>`;
        this.deleteButton = this.element.querySelector('.btn.btn-danger');
        this.confirmButton = this.element.querySelector('.btn.btn-primary');
    }
}

